@dfns/sdk 0.0.0-prealpha.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/baseAuthApi.d.ts +96 -0
  2. package/baseAuthApi.js +73 -0
  3. package/codegen/Assets/AssetsClient.d.ts +13 -0
  4. package/codegen/Assets/AssetsClient.js +94 -0
  5. package/codegen/Assets/DelegatedAssetsClient.d.ts +16 -0
  6. package/codegen/Assets/DelegatedAssetsClient.js +125 -0
  7. package/codegen/Assets/index.d.ts +3 -0
  8. package/codegen/Assets/index.js +19 -0
  9. package/codegen/Assets/types.d.ts +37 -0
  10. package/codegen/Assets/types.js +2 -0
  11. package/codegen/Auth/AuthClient.d.ts +48 -0
  12. package/codegen/Auth/AuthClient.js +494 -0
  13. package/codegen/Auth/DelegatedAuthClient.d.ts +74 -0
  14. package/codegen/Auth/DelegatedAuthClient.js +882 -0
  15. package/codegen/Auth/index.d.ts +3 -0
  16. package/codegen/Auth/index.js +19 -0
  17. package/codegen/Auth/types.d.ts +169 -0
  18. package/codegen/Auth/types.js +2 -0
  19. package/codegen/Blockchains/BlockchainsClient.d.ts +7 -0
  20. package/codegen/Blockchains/BlockchainsClient.js +23 -0
  21. package/codegen/Blockchains/DelegatedBlockchainsClient.d.ts +7 -0
  22. package/codegen/Blockchains/DelegatedBlockchainsClient.js +23 -0
  23. package/codegen/Blockchains/index.d.ts +3 -0
  24. package/codegen/Blockchains/index.js +19 -0
  25. package/codegen/Blockchains/types.d.ts +6 -0
  26. package/codegen/Blockchains/types.js +2 -0
  27. package/codegen/Callbacks/CallbacksClient.d.ts +12 -0
  28. package/codegen/Callbacks/CallbacksClient.js +78 -0
  29. package/codegen/Callbacks/DelegatedCallbacksClient.d.ts +15 -0
  30. package/codegen/Callbacks/DelegatedCallbacksClient.js +110 -0
  31. package/codegen/Callbacks/index.d.ts +3 -0
  32. package/codegen/Callbacks/index.js +19 -0
  33. package/codegen/Callbacks/types.d.ts +23 -0
  34. package/codegen/Callbacks/types.js +2 -0
  35. package/codegen/Permissions/DelegatedPermissionsClient.d.ts +27 -0
  36. package/codegen/Permissions/DelegatedPermissionsClient.js +285 -0
  37. package/codegen/Permissions/PermissionsClient.d.ts +18 -0
  38. package/codegen/Permissions/PermissionsClient.js +157 -0
  39. package/codegen/Permissions/index.d.ts +3 -0
  40. package/codegen/Permissions/index.js +19 -0
  41. package/codegen/Permissions/types.d.ts +62 -0
  42. package/codegen/Permissions/types.js +2 -0
  43. package/codegen/PolicyExecution/DelegatedPolicyExecutionClient.d.ts +11 -0
  44. package/codegen/PolicyExecution/DelegatedPolicyExecutionClient.js +62 -0
  45. package/codegen/PolicyExecution/PolicyExecutionClient.d.ts +9 -0
  46. package/codegen/PolicyExecution/PolicyExecutionClient.js +46 -0
  47. package/codegen/PolicyExecution/index.d.ts +3 -0
  48. package/codegen/PolicyExecution/index.js +19 -0
  49. package/codegen/PolicyExecution/types.d.ts +18 -0
  50. package/codegen/PolicyExecution/types.js +2 -0
  51. package/codegen/PolicyManagement/DelegatedPolicyManagementClient.d.ts +25 -0
  52. package/codegen/PolicyManagement/DelegatedPolicyManagementClient.js +241 -0
  53. package/codegen/PolicyManagement/PolicyManagementClient.d.ts +18 -0
  54. package/codegen/PolicyManagement/PolicyManagementClient.js +147 -0
  55. package/codegen/PolicyManagement/index.d.ts +3 -0
  56. package/codegen/PolicyManagement/index.js +19 -0
  57. package/codegen/PolicyManagement/types.d.ts +51 -0
  58. package/codegen/PolicyManagement/types.js +2 -0
  59. package/codegen/PublicKeys/DelegatedPublicKeysClient.d.ts +21 -0
  60. package/codegen/PublicKeys/DelegatedPublicKeysClient.js +191 -0
  61. package/codegen/PublicKeys/PublicKeysClient.d.ts +16 -0
  62. package/codegen/PublicKeys/PublicKeysClient.js +130 -0
  63. package/codegen/PublicKeys/index.d.ts +3 -0
  64. package/codegen/PublicKeys/index.js +19 -0
  65. package/codegen/PublicKeys/types.d.ts +51 -0
  66. package/codegen/PublicKeys/types.js +2 -0
  67. package/codegen/Wallets/DelegatedWalletsClient.d.ts +26 -0
  68. package/codegen/Wallets/DelegatedWalletsClient.js +249 -0
  69. package/codegen/Wallets/WalletsClient.d.ts +21 -0
  70. package/codegen/Wallets/WalletsClient.js +188 -0
  71. package/codegen/Wallets/index.d.ts +3 -0
  72. package/codegen/Wallets/index.js +19 -0
  73. package/codegen/Wallets/types.d.ts +87 -0
  74. package/codegen/Wallets/types.js +2 -0
  75. package/codegen/datamodel/Assets/errors.d.ts +11 -0
  76. package/codegen/datamodel/Assets/errors.js +17 -0
  77. package/codegen/datamodel/Assets/index.d.ts +3 -0
  78. package/codegen/datamodel/Assets/index.js +19 -0
  79. package/codegen/datamodel/Assets/responses.d.ts +47 -0
  80. package/codegen/datamodel/Assets/responses.js +2 -0
  81. package/codegen/datamodel/Assets/types.d.ts +225 -0
  82. package/codegen/datamodel/Assets/types.js +75 -0
  83. package/codegen/datamodel/Auth/index.d.ts +2 -0
  84. package/codegen/datamodel/Auth/index.js +18 -0
  85. package/codegen/datamodel/Auth/responses.d.ts +348 -0
  86. package/codegen/datamodel/Auth/responses.js +2 -0
  87. package/codegen/datamodel/Auth/types.d.ts +610 -0
  88. package/codegen/datamodel/Auth/types.js +127 -0
  89. package/codegen/datamodel/Blockchains/index.d.ts +2 -0
  90. package/codegen/datamodel/Blockchains/index.js +18 -0
  91. package/codegen/datamodel/Blockchains/responses.d.ts +12 -0
  92. package/codegen/datamodel/Blockchains/responses.js +2 -0
  93. package/codegen/datamodel/Blockchains/types.d.ts +269 -0
  94. package/codegen/datamodel/Blockchains/types.js +53 -0
  95. package/codegen/datamodel/Callbacks/index.d.ts +2 -0
  96. package/codegen/datamodel/Callbacks/index.js +18 -0
  97. package/codegen/datamodel/Callbacks/responses.d.ts +36 -0
  98. package/codegen/datamodel/Callbacks/responses.js +2 -0
  99. package/codegen/datamodel/Callbacks/types.d.ts +43 -0
  100. package/codegen/datamodel/Callbacks/types.js +39 -0
  101. package/codegen/datamodel/Foundations/errors.d.ts +121 -0
  102. package/codegen/datamodel/Foundations/errors.js +169 -0
  103. package/codegen/datamodel/Foundations/index.d.ts +2 -0
  104. package/codegen/datamodel/Foundations/index.js +18 -0
  105. package/codegen/datamodel/Foundations/types.d.ts +9756 -0
  106. package/codegen/datamodel/Foundations/types.js +57753 -0
  107. package/codegen/datamodel/Permissions/index.d.ts +2 -0
  108. package/codegen/datamodel/Permissions/index.js +18 -0
  109. package/codegen/datamodel/Permissions/responses.d.ts +75 -0
  110. package/codegen/datamodel/Permissions/responses.js +2 -0
  111. package/codegen/datamodel/Permissions/types.d.ts +93 -0
  112. package/codegen/datamodel/Permissions/types.js +43 -0
  113. package/codegen/datamodel/PolicyExecution/errors.d.ts +11 -0
  114. package/codegen/datamodel/PolicyExecution/errors.js +17 -0
  115. package/codegen/datamodel/PolicyExecution/index.d.ts +3 -0
  116. package/codegen/datamodel/PolicyExecution/index.js +19 -0
  117. package/codegen/datamodel/PolicyExecution/responses.d.ts +19 -0
  118. package/codegen/datamodel/PolicyExecution/responses.js +2 -0
  119. package/codegen/datamodel/PolicyExecution/types.d.ts +45 -0
  120. package/codegen/datamodel/PolicyExecution/types.js +15 -0
  121. package/codegen/datamodel/PolicyManagement/index.d.ts +2 -0
  122. package/codegen/datamodel/PolicyManagement/index.js +18 -0
  123. package/codegen/datamodel/PolicyManagement/responses.d.ts +83 -0
  124. package/codegen/datamodel/PolicyManagement/responses.js +2 -0
  125. package/codegen/datamodel/PolicyManagement/types.d.ts +212 -0
  126. package/codegen/datamodel/PolicyManagement/types.js +77 -0
  127. package/codegen/datamodel/PublicKeys/index.d.ts +2 -0
  128. package/codegen/datamodel/PublicKeys/index.js +18 -0
  129. package/codegen/datamodel/PublicKeys/responses.d.ts +56 -0
  130. package/codegen/datamodel/PublicKeys/responses.js +2 -0
  131. package/codegen/datamodel/PublicKeys/types.d.ts +222 -0
  132. package/codegen/datamodel/PublicKeys/types.js +59 -0
  133. package/codegen/datamodel/Wallets/index.d.ts +2 -0
  134. package/codegen/datamodel/Wallets/index.js +18 -0
  135. package/codegen/datamodel/Wallets/responses.d.ts +77 -0
  136. package/codegen/datamodel/Wallets/responses.js +2 -0
  137. package/codegen/datamodel/Wallets/types.d.ts +277 -0
  138. package/codegen/datamodel/Wallets/types.js +123 -0
  139. package/dfnsApiClient.d.ts +27 -0
  140. package/dfnsApiClient.js +45 -0
  141. package/dfnsAuthenticator.d.ts +17 -0
  142. package/dfnsAuthenticator.js +29 -0
  143. package/dfnsDelegatedApiClient.d.ts +24 -0
  144. package/dfnsDelegatedApiClient.js +41 -0
  145. package/dfnsError.d.ts +5 -0
  146. package/dfnsError.js +11 -0
  147. package/index.d.ts +7 -0
  148. package/index.js +23 -0
  149. package/package.json +11 -0
  150. package/signer.d.ts +42 -0
  151. package/signer.js +2 -0
  152. package/store.d.ts +79 -0
  153. package/store.js +2 -0
  154. package/utils/base64.d.ts +3 -0
  155. package/utils/base64.js +20 -0
  156. package/utils/fetch.d.ts +12 -0
  157. package/utils/fetch.js +89 -0
  158. package/utils/nonce.d.ts +1 -0
  159. package/utils/nonce.js +12 -0
  160. package/utils/url.d.ts +4 -0
  161. package/utils/url.js +15 -0
package/dfnsError.js ADDED
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DfnsError = void 0;
4
+ class DfnsError extends Error {
5
+ constructor(httpStatus, message, context) {
6
+ super(message);
7
+ this.httpStatus = httpStatus;
8
+ this.context = context;
9
+ }
10
+ }
11
+ exports.DfnsError = DfnsError;
package/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export * from './baseAuthApi';
2
+ export * from './dfnsApiClient';
3
+ export * from './dfnsAuthenticator';
4
+ export * from './dfnsDelegatedApiClient';
5
+ export * from './dfnsError';
6
+ export * from './signer';
7
+ export * from './store';
package/index.js ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./baseAuthApi"), exports);
18
+ __exportStar(require("./dfnsApiClient"), exports);
19
+ __exportStar(require("./dfnsAuthenticator"), exports);
20
+ __exportStar(require("./dfnsDelegatedApiClient"), exports);
21
+ __exportStar(require("./dfnsError"), exports);
22
+ __exportStar(require("./signer"), exports);
23
+ __exportStar(require("./store"), exports);
package/package.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "@dfns/sdk",
3
+ "version": "0.0.0-prealpha.9",
4
+ "dependencies": {
5
+ "buffer": "^6.0.3",
6
+ "cross-fetch": "^3.1.6",
7
+ "uuid": "9.0.0"
8
+ },
9
+ "main": "./index.js",
10
+ "types": "./index.d.ts"
11
+ }
package/signer.d.ts ADDED
@@ -0,0 +1,42 @@
1
+ export type CredentialKind = 'Key' | 'Fido2' | 'Password' | 'Totp' | 'RecoveryKey';
2
+ export type CredentialTransport = 'usb' | 'nfc' | 'ble' | 'internal';
3
+ export type AllowCredential = {
4
+ type: 'public-key';
5
+ id: string;
6
+ transports: CredentialTransport[];
7
+ };
8
+ export type KeyAssertion = {
9
+ kind: 'Key';
10
+ credentialAssertion: {
11
+ credId: string;
12
+ clientData: string;
13
+ signature: string;
14
+ };
15
+ };
16
+ export type Fido2Assertion = {
17
+ kind: 'Fido2';
18
+ credentialAssertion: {
19
+ credId: string;
20
+ clientData: string;
21
+ authenticatorData: string;
22
+ signature: string;
23
+ userHandle?: string;
24
+ };
25
+ };
26
+ export type PasswordAssertion = {
27
+ kind: 'Password';
28
+ password: string;
29
+ };
30
+ export type TotpAssertion = {
31
+ kind: 'Totp';
32
+ otpCode: string;
33
+ };
34
+ export type FirstFactorAssertion = KeyAssertion | Fido2Assertion | PasswordAssertion;
35
+ export type SecondFactorAssertion = KeyAssertion | Fido2Assertion | TotpAssertion;
36
+ export type CredentialAssertion = KeyAssertion | Fido2Assertion | PasswordAssertion | TotpAssertion;
37
+ export interface CredentialSigner<T extends CredentialAssertion = FirstFactorAssertion> {
38
+ sign(challenge: string, allowCredentials: {
39
+ key: AllowCredential[];
40
+ webauthn: AllowCredential[];
41
+ }): Promise<T>;
42
+ }
package/signer.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/store.d.ts ADDED
@@ -0,0 +1,79 @@
1
+ import { AllowCredential, CredentialKind } from './signer';
2
+ export type AuthenticatorAttachment = 'platform' | 'cross-platform';
3
+ export type ResidentKeyRequirement = 'required' | 'preferred' | 'discouraged';
4
+ export type UserVerificationRequirement = 'required' | 'preferred' | 'discouraged';
5
+ export type AttestationConveyancePreference = 'none' | 'indirect' | 'direct' | 'enterprise';
6
+ export type UserRegistrationChallenge = {
7
+ temporaryAuthenticationToken: string;
8
+ rp: {
9
+ id: string;
10
+ name: string;
11
+ };
12
+ user: {
13
+ id: string;
14
+ name: string;
15
+ displayName: string;
16
+ };
17
+ supportedCredentialKinds: {
18
+ firstFactor: CredentialKind[];
19
+ secondFactor: CredentialKind[];
20
+ };
21
+ otpUrl: string;
22
+ challenge: string;
23
+ authenticatorSelection: {
24
+ authenticatorAttachment?: AuthenticatorAttachment;
25
+ requireResidentKey: boolean;
26
+ residentKey: ResidentKeyRequirement;
27
+ userVerification: UserVerificationRequirement;
28
+ };
29
+ attestation: AttestationConveyancePreference;
30
+ pubKeyCredParams: {
31
+ type: 'public-key';
32
+ alg: number;
33
+ }[];
34
+ excludeCredentials: AllowCredential[];
35
+ };
36
+ export type KeyAttestation = {
37
+ credentialKind: 'Key';
38
+ credentialInfo: {
39
+ credId: string;
40
+ clientData: string;
41
+ attestationData: string;
42
+ };
43
+ };
44
+ export type Fido2Attestation = {
45
+ credentialKind: 'Fido2';
46
+ credentialInfo: {
47
+ credId: string;
48
+ clientData: string;
49
+ attestationData: string;
50
+ };
51
+ };
52
+ export type PasswordAttestation = {
53
+ credentialKind: 'Password';
54
+ credentialInfo: {
55
+ password: string;
56
+ };
57
+ };
58
+ export type TotpAttestation = {
59
+ credentialKind: 'Totp';
60
+ credentialInfo: {
61
+ otpCode: string;
62
+ };
63
+ };
64
+ export type FirstFactorAttestation = KeyAttestation | Fido2Attestation | PasswordAttestation;
65
+ export type SecondFactorAttestation = KeyAttestation | Fido2Attestation | TotpAttestation;
66
+ export type RecoveryKeyAttestation = {
67
+ credentialKind: 'RecoveryKey';
68
+ credentialInfo: {
69
+ credId: string;
70
+ clientData: string;
71
+ attestationData: string;
72
+ };
73
+ encryptedPrivateKey?: string;
74
+ };
75
+ export type RecoveryFactorAttestation = RecoveryKeyAttestation;
76
+ export type CredentialAttestation = KeyAttestation | Fido2Attestation | PasswordAttestation | TotpAttestation | RecoveryKeyAttestation;
77
+ export interface CredentialStore<T extends CredentialAttestation = FirstFactorAttestation> {
78
+ create(challenge: UserRegistrationChallenge): Promise<T>;
79
+ }
package/store.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ import { Buffer } from 'buffer';
2
+ export declare const toBase64Url: (buffer: string | Buffer) => string;
3
+ export declare const fromBase64Url: (encoded: string) => Buffer;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fromBase64Url = exports.toBase64Url = void 0;
4
+ const buffer_1 = require("buffer");
5
+ const toBase64Url = (buffer) => {
6
+ if (typeof buffer === 'string') {
7
+ buffer = buffer_1.Buffer.from(buffer);
8
+ }
9
+ return buffer.toString('base64').replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_');
10
+ };
11
+ exports.toBase64Url = toBase64Url;
12
+ const fromBase64Url = (encoded) => {
13
+ const padLength = 4 - (encoded.length % 4);
14
+ if (padLength < 4) {
15
+ encoded += '='.repeat(padLength);
16
+ }
17
+ encoded = encoded.replace(/\-/g, '+').replace(/_/g, '/');
18
+ return buffer_1.Buffer.from(encoded, 'base64');
19
+ };
20
+ exports.fromBase64Url = fromBase64Url;
@@ -0,0 +1,12 @@
1
+ import { DfnsBaseApiOptions } from '../baseAuthApi';
2
+ import { DfnsApiClientOptions } from '../dfnsApiClient';
3
+ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';
4
+ export type FetchOptions<T> = {
5
+ method: HttpMethod;
6
+ headers?: Record<string, string>;
7
+ body?: string | unknown;
8
+ apiOptions: T;
9
+ };
10
+ export type Fetch<T> = (resource: string | URL, options: FetchOptions<T>) => Promise<Response>;
11
+ export declare const simpleFetch: Fetch<DfnsBaseApiOptions>;
12
+ export declare const userActionFetch: Fetch<DfnsApiClientOptions>;
package/utils/fetch.js ADDED
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.userActionFetch = exports.simpleFetch = void 0;
4
+ const cross_fetch_1 = require("cross-fetch");
5
+ const dfnsError_1 = require("../dfnsError");
6
+ const baseAuthApi_1 = require("../baseAuthApi");
7
+ const nonce_1 = require("./nonce");
8
+ const fullUrl = (fetch) => {
9
+ return async (resource, options) => {
10
+ const { baseUrl } = options.apiOptions;
11
+ resource = new URL(resource, baseUrl);
12
+ return fetch(resource, options);
13
+ };
14
+ };
15
+ const jsonSerializer = (fetch) => {
16
+ return async (resource, options) => {
17
+ var _a;
18
+ if (options.body) {
19
+ options.body = JSON.stringify(options.body);
20
+ options.headers = {
21
+ 'content-type': 'application/json',
22
+ ...((_a = options.headers) !== null && _a !== void 0 ? _a : {}),
23
+ };
24
+ }
25
+ return fetch(resource, options);
26
+ };
27
+ };
28
+ const errorHandler = (fetch) => {
29
+ return async (resource, options) => {
30
+ const response = await fetch(resource, options);
31
+ if (response.ok) {
32
+ return response;
33
+ }
34
+ else {
35
+ const body = await response.json();
36
+ throw new dfnsError_1.DfnsError(response.status, body.error.message, body.error);
37
+ }
38
+ };
39
+ };
40
+ const dfnsAuth = (fetch) => {
41
+ return async (resource, options) => {
42
+ var _a;
43
+ const { appId, appSecret, authToken } = options.apiOptions;
44
+ const authorization = authToken
45
+ ? {
46
+ authorization: `Bearer ${authToken}`,
47
+ }
48
+ : {};
49
+ const dfnsAppSecret = appSecret
50
+ ? {
51
+ 'x-dfns-appsecret': appSecret,
52
+ }
53
+ : {};
54
+ options.headers = {
55
+ 'x-dfns-appid': appId,
56
+ 'x-dfns-nonce': (0, nonce_1.generateNonce)(),
57
+ ...dfnsAppSecret,
58
+ ...authorization,
59
+ ...((_a = options.headers) !== null && _a !== void 0 ? _a : {}),
60
+ };
61
+ return fetch(resource, options);
62
+ };
63
+ };
64
+ const userAction = (fetch) => {
65
+ return async (resource, options) => {
66
+ var _a, _b;
67
+ if (options.method !== 'GET') {
68
+ const { challenge, challengeIdentifier, allowCredentials } = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
69
+ userActionPayload: (_a = options.body) !== null && _a !== void 0 ? _a : '',
70
+ userActionHttpMethod: options.method,
71
+ userActionHttpPath: resource.pathname,
72
+ userActionServerKind: 'Api',
73
+ }, options.apiOptions);
74
+ const { signer } = options.apiOptions;
75
+ const assertion = await signer.sign(challenge, allowCredentials);
76
+ const { userAction } = await baseAuthApi_1.BaseAuthApi.signUserActionChallenge({
77
+ challengeIdentifier,
78
+ firstFactor: assertion,
79
+ }, options.apiOptions);
80
+ options.headers = {
81
+ 'x-dfns-useraction': userAction,
82
+ ...((_b = options.headers) !== null && _b !== void 0 ? _b : {}),
83
+ };
84
+ }
85
+ return fetch(resource, options);
86
+ };
87
+ };
88
+ exports.simpleFetch = fullUrl(jsonSerializer(dfnsAuth(errorHandler(cross_fetch_1.fetch))));
89
+ exports.userActionFetch = fullUrl(jsonSerializer(dfnsAuth(userAction(errorHandler(cross_fetch_1.fetch)))));
@@ -0,0 +1 @@
1
+ export declare const generateNonce: () => string;
package/utils/nonce.js ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateNonce = void 0;
4
+ const uuid_1 = require("uuid");
5
+ const base64_1 = require("./base64");
6
+ const generateNonce = () => {
7
+ return (0, base64_1.toBase64Url)(JSON.stringify({
8
+ uuid: (0, uuid_1.v4)(),
9
+ date: new Date().toISOString(),
10
+ }));
11
+ };
12
+ exports.generateNonce = generateNonce;
package/utils/url.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export declare const buildPathAndQuery: (pattern: string, params: {
2
+ path: Record<string, string>;
3
+ query: Record<string, string | number | boolean | undefined>;
4
+ }) => string;
package/utils/url.js ADDED
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildPathAndQuery = void 0;
4
+ const buildPathAndQuery = (pattern, params) => {
5
+ let path = pattern;
6
+ for (const key in params.path) {
7
+ path = path.replace(new RegExp(`:${key}`, 'g'), encodeURIComponent(params.path[key]));
8
+ }
9
+ const query = Object.entries(params.query)
10
+ .filter(([_, value]) => !!value)
11
+ .map(([key, value]) => `${key}=${encodeURIComponent(value.toString())}`)
12
+ .join('&');
13
+ return query === '' ? path : `${path}?${query}`;
14
+ };
15
+ exports.buildPathAndQuery = buildPathAndQuery;