Skip to content

Commit aa939ce

Browse files
docs: access keys and guards references in typescript (#675)
* docs: access keys and guards references in typescript Signed-off-by: David Dal Busco <david.dalbusco@outlook.com> * 📄 Update LLMs.txt snapshot for PR review * docs: access keys fn Signed-off-by: David Dal Busco <david.dalbusco@outlook.com> * 📄 Update LLMs.txt snapshot for PR review --------- Signed-off-by: David Dal Busco <david.dalbusco@outlook.com> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent df67b94 commit aa939ce

File tree

2 files changed

+380
-0
lines changed

2 files changed

+380
-0
lines changed

.llms-snapshots/llms-full.txt

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13368,6 +13368,196 @@ function getContentChunksStore( params: GetContentChunksStoreParams): Blob | un
1336813368
* `ZodError` if the input schema is invalid.
1336913369
* `Error` if the operation fails.
1337013370

13371+
---
13372+
13373+
## Access Keys
13374+
13375+
The following functions allow you to inspect and assert the access keys of your Satellite.
13376+
13377+
---
13378+
13379+
### getAccessKeys
13380+
13381+
Retrieves all access keys of the Satellite.
13382+
13383+
```
13384+
function getAccessKeys(): AccessKeys;
13385+
```
13386+
13387+
📦 Import from `@junobuild/functions/sdk`
13388+
13389+
#### Returns:
13390+
13391+
* `AccessKeys`: The list of all access keys.
13392+
13393+
#### Throws:
13394+
13395+
* `ZodError` if the returned value does not match the expected schema.
13396+
13397+
---
13398+
13399+
### getAdminAccessKeys
13400+
13401+
Retrieves only the admin access keys of the Satellite.
13402+
13403+
```
13404+
function getAdminAccessKeys(): AccessKeys;
13405+
```
13406+
13407+
📦 Import from `@junobuild/functions/sdk`
13408+
13409+
#### Returns:
13410+
13411+
* `AccessKeys`: The list of admin access keys.
13412+
13413+
#### Throws:
13414+
13415+
* `ZodError` if the returned value does not match the expected schema.
13416+
13417+
---
13418+
13419+
### isWriteAccessKey
13420+
13421+
Checks if the given id is a non-expired access key with admin or write scope.
13422+
13423+
```
13424+
function isWriteAccessKey(params: AccessKeyCheckParams): boolean;
13425+
```
13426+
13427+
📦 Import from `@junobuild/functions/sdk`
13428+
13429+
#### Parameters:
13430+
13431+
* `params`: An object containing:
13432+
* `id`: The principal to check (`RawUserId` or `UserId`).
13433+
* `accessKeys`: The list of access keys to verify against.
13434+
13435+
#### Returns:
13436+
13437+
* `boolean`: Whether the id is an access key with write permission.
13438+
13439+
#### Throws:
13440+
13441+
* `ZodError` if any input does not match the expected schema.
13442+
13443+
---
13444+
13445+
### isValidAccessKey
13446+
13447+
Checks if the given id is a non-expired access key regardless of scope (admin, write, or submit).
13448+
13449+
```
13450+
function isValidAccessKey(params: AccessKeyCheckParams): boolean;
13451+
```
13452+
13453+
📦 Import from `@junobuild/functions/sdk`
13454+
13455+
#### Parameters:
13456+
13457+
* `params`: An object containing:
13458+
* `id`: The principal to check (`RawUserId` or `UserId`).
13459+
* `accessKeys`: The list of access keys to verify against.
13460+
13461+
#### Returns:
13462+
13463+
* `boolean`: Whether the id is a recognized access key.
13464+
13465+
#### Throws:
13466+
13467+
* `ZodError` if any input does not match the expected schema.
13468+
13469+
---
13470+
13471+
### isAdminController
13472+
13473+
Checks if the given id is an admin access key and a controller known by the Internet Computer.
13474+
13475+
```
13476+
function isAdminController(params: AccessKeyCheckParams): boolean;
13477+
```
13478+
13479+
📦 Import from `@junobuild/functions/sdk`
13480+
13481+
#### Parameters:
13482+
13483+
* `params`: An object containing:
13484+
* `id`: The principal to check (`RawUserId` or `UserId`).
13485+
* `accessKeys`: The list of access keys to verify against.
13486+
13487+
#### Returns:
13488+
13489+
* `boolean`: Whether the id is an admin and a controller of the Satellite.
13490+
13491+
#### Throws:
13492+
13493+
* `ZodError` if any input does not match the expected schema.
13494+
13495+
---
13496+
13497+
## Guards
13498+
13499+
The following guard functions can be used to validate the caller in your custom serverless functions.
13500+
13501+
---
13502+
13503+
### callerIsAdmin
13504+
13505+
Guards that the caller is an admin access key of this satellite. Admin access keys have full management privileges and never expire.
13506+
13507+
```
13508+
function callerIsAdmin(): void;
13509+
```
13510+
13511+
📦 Import from `@junobuild/functions/sdk`
13512+
13513+
#### Returns:
13514+
13515+
* `void`
13516+
13517+
#### Throws:
13518+
13519+
* `ZodError` if the caller is not an admin access key.
13520+
13521+
---
13522+
13523+
### callerHasWritePermission
13524+
13525+
Guards that the caller has write permission. Admin and editor access keys pass; submitter access keys do not.
13526+
13527+
```
13528+
function callerHasWritePermission(): void;
13529+
```
13530+
13531+
📦 Import from `@junobuild/functions/sdk`
13532+
13533+
#### Returns:
13534+
13535+
* `void`
13536+
13537+
#### Throws:
13538+
13539+
* `ZodError` if the caller does not have write permission.
13540+
13541+
---
13542+
13543+
### callerIsAccessKey
13544+
13545+
Guards that the caller is any recognized access key of this satellite. Accepts admin, editor, and submitter access keys alike.
13546+
13547+
```
13548+
function callerIsAccessKey(): void;
13549+
```
13550+
13551+
📦 Import from `@junobuild/functions/sdk`
13552+
13553+
#### Returns:
13554+
13555+
* `void`
13556+
13557+
#### Throws:
13558+
13559+
* `ZodError` if the caller is not a recognized access key.
13560+
1337113561
# Utils
1337213562

1337313563
The following utilities are provided to help you work with document and asset data inside your Satellite. They simplify tasks such as decoding and encoding data, serializing custom types, and interacting with Juno’s core features in a consistent way.

docs/reference/functions/typescript/sdk.mdx

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,3 +541,193 @@ function getContentChunksStore(
541541

542542
- `ZodError` if the input schema is invalid.
543543
- `Error` if the operation fails.
544+
545+
---
546+
547+
## Access Keys
548+
549+
The following functions allow you to inspect and assert the access keys of your Satellite.
550+
551+
---
552+
553+
### getAccessKeys
554+
555+
Retrieves all access keys of the Satellite.
556+
557+
```typescript
558+
function getAccessKeys(): AccessKeys;
559+
```
560+
561+
📦 Import from `@junobuild/functions/sdk`
562+
563+
#### Returns:
564+
565+
- `AccessKeys`: The list of all access keys.
566+
567+
#### Throws:
568+
569+
- `ZodError` if the returned value does not match the expected schema.
570+
571+
---
572+
573+
### getAdminAccessKeys
574+
575+
Retrieves only the admin access keys of the Satellite.
576+
577+
```typescript
578+
function getAdminAccessKeys(): AccessKeys;
579+
```
580+
581+
📦 Import from `@junobuild/functions/sdk`
582+
583+
#### Returns:
584+
585+
- `AccessKeys`: The list of admin access keys.
586+
587+
#### Throws:
588+
589+
- `ZodError` if the returned value does not match the expected schema.
590+
591+
---
592+
593+
### isWriteAccessKey
594+
595+
Checks if the given id is a non-expired access key with admin or write scope.
596+
597+
```typescript
598+
function isWriteAccessKey(params: AccessKeyCheckParams): boolean;
599+
```
600+
601+
📦 Import from `@junobuild/functions/sdk`
602+
603+
#### Parameters:
604+
605+
- `params`: An object containing:
606+
- `id`: The principal to check (`RawUserId` or `UserId`).
607+
- `accessKeys`: The list of access keys to verify against.
608+
609+
#### Returns:
610+
611+
- `boolean`: Whether the id is an access key with write permission.
612+
613+
#### Throws:
614+
615+
- `ZodError` if any input does not match the expected schema.
616+
617+
---
618+
619+
### isValidAccessKey
620+
621+
Checks if the given id is a non-expired access key regardless of scope (admin, write, or submit).
622+
623+
```typescript
624+
function isValidAccessKey(params: AccessKeyCheckParams): boolean;
625+
```
626+
627+
📦 Import from `@junobuild/functions/sdk`
628+
629+
#### Parameters:
630+
631+
- `params`: An object containing:
632+
- `id`: The principal to check (`RawUserId` or `UserId`).
633+
- `accessKeys`: The list of access keys to verify against.
634+
635+
#### Returns:
636+
637+
- `boolean`: Whether the id is a recognized access key.
638+
639+
#### Throws:
640+
641+
- `ZodError` if any input does not match the expected schema.
642+
643+
---
644+
645+
### isAdminController
646+
647+
Checks if the given id is an admin access key and a controller known by the Internet Computer.
648+
649+
```typescript
650+
function isAdminController(params: AccessKeyCheckParams): boolean;
651+
```
652+
653+
📦 Import from `@junobuild/functions/sdk`
654+
655+
#### Parameters:
656+
657+
- `params`: An object containing:
658+
- `id`: The principal to check (`RawUserId` or `UserId`).
659+
- `accessKeys`: The list of access keys to verify against.
660+
661+
#### Returns:
662+
663+
- `boolean`: Whether the id is an admin and a controller of the Satellite.
664+
665+
#### Throws:
666+
667+
- `ZodError` if any input does not match the expected schema.
668+
669+
---
670+
671+
## Guards
672+
673+
The following guard functions can be used to validate the caller in your custom serverless functions.
674+
675+
---
676+
677+
### callerIsAdmin
678+
679+
Guards that the caller is an admin access key of this satellite. Admin access keys have full management privileges and never expire.
680+
681+
```typescript
682+
function callerIsAdmin(): void;
683+
```
684+
685+
📦 Import from `@junobuild/functions/sdk`
686+
687+
#### Returns:
688+
689+
- `void`
690+
691+
#### Throws:
692+
693+
- `ZodError` if the caller is not an admin access key.
694+
695+
---
696+
697+
### callerHasWritePermission
698+
699+
Guards that the caller has write permission. Admin and editor access keys pass; submitter access keys do not.
700+
701+
```typescript
702+
function callerHasWritePermission(): void;
703+
```
704+
705+
📦 Import from `@junobuild/functions/sdk`
706+
707+
#### Returns:
708+
709+
- `void`
710+
711+
#### Throws:
712+
713+
- `ZodError` if the caller does not have write permission.
714+
715+
---
716+
717+
### callerIsAccessKey
718+
719+
Guards that the caller is any recognized access key of this satellite. Accepts admin, editor, and submitter access keys alike.
720+
721+
```typescript
722+
function callerIsAccessKey(): void;
723+
```
724+
725+
📦 Import from `@junobuild/functions/sdk`
726+
727+
#### Returns:
728+
729+
- `void`
730+
731+
#### Throws:
732+
733+
- `ZodError` if the caller is not a recognized access key.

0 commit comments

Comments
 (0)